from os import name
from typing import *
from flask import Flask, render_template

app = Flask(__name__)

@app.route("/")
@app.route("/my_filter")
def my_filter():
    data = {
        "url" : "www.baidu.com",
        "list" : [1, 2, 3, 4, 5]
    }
    return render_template(template_name_or_list="filter.html", data=data)


def my_filter(list: List) -> Union[float, int]:
    return str(sum(list))


# 使用自己的过滤器最重要的在于自定义过滤器
app.add_template_filter(
    f=my_filter, name="my_filter"
)

if __name__ == "__main__":
    app.run()